﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Soft.Service
{
    /// <summary>
    /// 获取job功能集合列表
    /// </summary>
    public sealed class GetJobsRemoteControlProcessor : BaseRemoteControlProcessor
    {
        public GetJobsRemoteControlProcessor()
        {
            Console.WriteLine($"获取Job功能列表集合");
        }

        /// <summary>
        /// 获取job功能集合列表
        /// </summary>
        /// <param name="processCollection"></param>
        public GetJobsRemoteControlProcessor(ProcessCollection processCollection)
        {
            if (processCollection == null)
            {
                throw new ArgumentNullException("processCollection");
            }
            this.mProcessCollection = processCollection;
        }


        /// <summary>
        /// 获取功能列表
        /// </summary>
        /// <param name="jsonParam"></param>
        /// <returns></returns>
        public override ResultJson Processing(string jsonParam)
        {
            List<GetJobsCommandResult> list = new List<GetJobsCommandResult>();
            foreach (ProcessItem processItem in this.mProcessCollection.ProcessItems)
            {
                list.Add(new GetJobsCommandResult
                {
                    FunctionCode = processItem.FunctionSign.FullCode,
                    Explain = processItem.Method.Explain
                });
            }
            return new ResultJson
            {
                Json = JsonConvertHelper.ToJson(list)
            };
        }

        
        /// <summary>
        /// 功能集合
        /// </summary>
        private ProcessCollection mProcessCollection;
    }
}
